package com.vincent.springamqpdemo;

import org.apache.activemq.command.ActiveMQQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

/**
 * @author vincent
 * @DATE 2018/11/3
 * @Description
 */
@Service
public class JmsService {
    private static Logger logger = LoggerFactory.getLogger(JmsService.class);
    @Autowired
    private JmsTemplate jmsTemplate;

    public void send(String queue, String value) {
        jmsTemplate.convertAndSend(new ActiveMQQueue(queue), value);
    }

    public String revceive(String queue){
        return (String) jmsTemplate.receiveAndConvert(new ActiveMQQueue(queue));
    }
}
